﻿// owner 蒋家伟

#pragma once

// jsdk
#include "IFieldReflectManager.h"
#include "IClassFieldDescriptor.h"
#include "QueryableList.h"
#include "UniqueId.h"

namespace jsdk
{
    class FieldReflectManager : public IFieldReflectManager
    {
        using ClassFieldDescriptorContainer = typename QueryableList<std::wstring, OwnerPtr<IClassFieldDescriptor>>;

    public:
        // 继承IFieldReflectManager
        virtual bool registerReflectField(OwnerPtr<IClassFieldDescriptor> opClassFieldDescriptor) override;
        virtual uint64_t getFieldCount() const override;
        virtual const IClassFieldDescriptor* getFieldDescriptor(const std::wstring& fieldVariableName) const override;
        virtual IClassFieldDescriptor* getFieldDescriptor(const std::wstring& fieldVariableName) override;
        virtual const std::wstring& getOwnerClassTypeName() const override;
        virtual const UniqueId& getOwnerClassTypeUid() const override;
        void setClassAddress(void* pClassAddress);

        // owner
        FieldReflectManager(const UniqueId& ownerClassTypeUid, const std::wstring& ownerClassTypeName);

    private:
        ClassFieldDescriptorContainer m_variableNameToFieldDescriptorList;
        std::wstring m_ownerClassTypeName;
        jsdk::UniqueId m_ownerClassTypeUid;
    };
}
